#ifndef _NODE_H_
#define _NODE_H_

#include <cstdlib>

class Node
{
public:
    Node(int data): m_data(data), m_next(NULL) {}
    Node(const Node & node): m_data(node.m_data), m_next(NULL) {}
    Node(const Node * const pnode): m_data(pnode->m_data), m_next(NULL) {}
    ~Node(){}
    Node & operator = (const Node & node)
    {
        if (this != &node)
        {
            m_data = node.m_data;
            m_next = NULL;
        }
        return *this;
    }
    // member access
    const int data() const { return m_data; }
    Node * const next() const { return m_next; }
    // capacity
    int count_to_end() const;
    // element access
    Node * const end() const;
    // modifiers
    void set_next(Node * node) { m_next = node; }
    Node * const append_to_end(Node * node)
    {
        end()->m_next = node;
    }
    Node * const append_to_end(int data)
    {
        end()->m_next = new Node(data);
    }
private:
    int m_data;
    Node * m_next;
};

#endif

